<template>
	<view :class="['nav-bar', 0 == bg && 'bfw', 1 == bg && 'bf8']" :style="'padding-top:' + statusBarHeight + 'px'">
		<view class="navbar-item df" :style="'height:' + titleBarHeight + 'px'">
			<view class="back-box df" :style="'height:' + titleBarHeight + 'px'" @click="navBack">
				<image src="/static/img/z.png"></image>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		props: {
			bg: { type: Number, default: 0 },
		},
		data() {
			return {
				statusBarHeight: app.globalData.statusBarHeight,
				titleBarHeight: app.globalData.titleBarHeight,
			}
		},
		methods: {
			navBack() {
				if(getCurrentPages().length > 1)
				{
					uni.navigateBack()
				}else{
					uni.switchTab({ url: "/pages/tabbar/index" });
				}
			}
		}
	}
</script>

<style>
	.nav-bar {
	  position: fixed;
	  top: 0;
	  left: 0;
	  right: 0;
	  width: 100%;
	  z-index: 99;
	  box-sizing: border-box;
	}
	.nav-bar .navbar-item {
	  width: 100%;
	}
	.navbar-item .back-box {
	  padding: 0 30rpx;
	}
	.navbar-item .back-box image {
	  width: 34rpx;
	  height: 34rpx;
	}

</style>